package other

import (
	"context"
	"fast-boot/app/api/wxapp/internal/svc"
	"fast-boot/app/api/wxapp/internal/types"
	"github.com/hwUltra/fb-tools/sms"
	"github.com/zeromicro/go-zero/core/logx"
)

type SendSmsLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewSendSmsLogic(ctx context.Context, svcCtx *svc.ServiceContext) SendSmsLogic {
	return SendSmsLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *SendSmsLogic) SendSms(req types.SendSmsReq) error {

	var smsClient = sms.NewVCode(l.svcCtx.Config.Sms, l.svcCtx.Config.Cache)
	if err := smsClient.Send(l.svcCtx.Config.Sms.Template["Reg"], req.Mobile); err != nil {
		return err
	}
	return nil
}
